feat: Add vendor auto-discovery from file contents#1195
Merged
Conversation
Add the ability to automatically detect the correct vendor/parser for a file without requiring the caller to specify it. This adds `vendor_from_file()` and `vendor_from_io()` public API functions, makes `vendor_type` optional in all existing API functions, and implements `sniff()` classmethods on all 53 parsers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…scover_vendor When multiple parsers sniff True for the same file (e.g. Gen5/Gen5Image), try parsing with each to disambiguate. If no sniff matches at all, try parsing with every extension-compatible candidate as a last resort. Also adds vendor auto-discovery guidance to CLAUDE.md for new parser development. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ajcariaga16
approved these changes
Apr 30, 2026
nathan-stender
added a commit
that referenced
this pull request
May 1, 2026
### Added - Add vendor auto-discovery from file contents (#1195)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vendor_from_file()andvendor_from_io()public API functions that auto-detect the correctVendorfor a file based on its contentsvendor_typeoptional (Nonedefault) inallotrope_from_file,allotrope_from_io,allotrope_model_from_file,allotrope_model_from_io— whenNone, auto-discovers the vendorAllotropeVendorNotFoundErrorexception raised when no parser matchessniff()classmethods on all 53 parsers with lightweight file-content checks (sheet names, header patterns, XML root tags, etc.)discover_vendor_test.pywith 309 parametrized tests verifying discovery against all existing test data filesDesign
discover_vendor()inparser_factory.pyruns a multi-pass detection strategy:sniff()on each candidate, collect all matchescreate_data()on each sniff match to disambiguate (e.g., Gen5 vs Gen5Image both sniff True for.txt, but only one parses successfully)create_data()on all candidates as brute-force fallbackEach parser's
sniff()is a lightweight classmethod: unique extensions returnTrue, shared extensions check distinctive content (header columns, sheet names, XML root tags, etc.). UTF-16 LE/BE encoded files are handled with BOM detection.Indistinguishable parser pairs (same file format, either parser works): Gen5/Gen5Image, xPONENT/IntelliFlex, VisionLite/GenesysOnBoard, EchoCherryPick/EchoPlateReformat, QuantStudio/QuantStudioD&A, MSDWorkbench/MethodicalMind.
Test plan
🤖 Generated with Claude Code